﻿$(function () {
    KindEditor.ready(function (K) {
        editor1 = K.create('#txtnote', {
            cssPath: '/Modules/CloudClass/Scripts/kindeditor/plugins/code/prettify.css',
            uploadJson: '/Modules/CloudClass/Scripts/kindeditor/asp.net/upload_json.ashx',
            fileManagerJson: '/Modules/CloudClass/Scripts/kindeditor/asp.net/file_manager_json.ashx',
            items: [
                'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'quickformat', 'selectall', '|',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image'
            ],
            allowFileManager: true
        });
    });


    //保存笔记
    $(".btn-primary").live("click", function () {
        var noteContent = editor1.html();
        if (noteContent.length == 0) {
            return false;
        }
        var option = {
            lessonId: $("#sellesson").val(),
            noteContent: noteContent,
            isPrivate: $('#chb').is(':checked'),
            courseId: $("#hdCourseId").val()
        };
        //console.log(option)
        common.ajax(function (data) {
            if (data.length > 0)
                location.href = "../Note/" + $("#hdCourseId").val();
        }, null, "../CreateNote", option, 'POST');
    });

    $("#btncancel").click(function() {
        location.href = location.href;
    });
})